package com.uui.action;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.uui.service.user.UserService;

@Controller
public class LoginAction {
	@Autowired
	UserService userService;

	@RequestMapping("show")
	public ModelAndView login(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mode = new ModelAndView("main");
		return mode;
	}

	@RequestMapping("gologin")
	public ModelAndView gologin(HttpServletRequest request, HttpServletResponse response) {
		Subject currentUser = SecurityUtils.getSubject();
		System.out.println(currentUser);
		ModelAndView mode = new ModelAndView();
		if (currentUser.isAuthenticated()) {
			mode.setViewName("main");
		} else {
			mode.setViewName("login");
		}
		return mode;
	}

	@RequestMapping("add")
	public ModelAndView add(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mode = new ModelAndView("add");
		return mode;
	}
}